﻿/**
 * 
 * 
 */

var scui = {
	// sbar: show sidebar
	keyCode: {
		ENTER: 13, ESC: 27, END: 35, HOME: 36,
		SHIFT: 16, TAB: 9,
		LEFT: 37, RIGHT: 39, UP: 38, DOWN: 40,
		DELETE: 46, BACKSPACE:8
	},
	statusCode: {ok:200, error:300, timeout:301},
	ui:{sbar:true},
	frag:{}, //page fragment
	_msg:{}, //alert message
	jsonEval:function (json) {
		try{
			return eval('(' + json + ')');
		} catch (e){
			return {};
		}
	},
	init: function(){
		
		scui.frag["dialogFrag"] = '<DIV style="BORDER-BOTTOM: #d1d1d1 1px solid; POSITION: absolute; BORDER-LEFT: #d1d1d1 1px solid; DISPLAY: block; BACKGROUND: url(../images/pop_03.gif) #f1f1f1 repeat-x 0px 0px; FLOAT: left;BORDER-TOP: #d1d1d1 1px solid;BORDER-RIGHT: #d1d1d1 1px solid;" id=popmessage class=popmessage><LI style="BORDER-BOTTOM: #d1d1d1 1px solid; WIDTH: 100%; DISPLAY: block; FLOAT: left; HEIGHT: 40px; COLOR: #0e4796; FONT-SIZE: 12px; FONT-WEIGHT: bold" id=popTitle class=popTitle><DIV style="PADDING-BOTTOM: 0px; PADDING-LEFT: 15px; PADDING-RIGHT: 0px; FLOAT: left; PADDING-TOP: 13px" id=titlename></DIV><DIV style="MARGIN: 13px 10px 0px 0px; WIDTH: 15px; DISPLAY: block; BACKGROUND: url(images/popClose.gif) no-repeat; FLOAT: right; HEIGHT: 15px; CURSOR: pointer;" id=popClose></DIV></LI><LI style="PADDING-BOTTOM: 10px;PADDING-LEFT: 30px; PADDING-RIGHT: 25px; DISPLAY: block; FLOAT: left; width:auto;PADDING-TOP: 15px" id=popcontent class=popcontent><div style="display:block;float:left;font-size:12px; font-weight:bold; padding:0 0 0 20px;">加载中...</div>	</LI><LI style="TEXT-ALIGN: center; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; DISPLAY: block; FLOAT: left; HEIGHT: 20px; VERTICAL-ALIGN: middle; BORDER-TOP: #d1d1d1 1px solid; PADDING-TOP: 5px;PADDING-BOTTOM: 5px" id=popbottom class=popbottom><INPUT style="display:none;" id=msg_btn_ok class=popButton value=确定 type=button name=btnok><INPUT style="display:none;" id=msg_btn_no class=popButton value=否 type=button name=btnno><INPUT style="display:none;" id=msg_btn_cancel class=popButtonCancel value=取消 type=button name=btncancel></LI></DIV>';
		scui.frag["mask"] = '<div id="div_mask" class="el-static-mask" style="top: 0pt; left: 0pt; width: 100%; height: 100%;display:none;"><div style="margin-top:250px;left:50%;"><img src="images/mteaf/loading.gif"></img>&nbsp;加载中...</div></div>';
		scui.frag["combox"] = '<div class="combox"></div>';
/*
jQuery.ajax({
			type:"GET",
			url:page,
			dataType:"xml",
			cache: false,
			error: function(xhr){
				alert('Error loading XML document: ' + page + "\nHttp status: " + xhr.status + " " + xhr.statusText);
			}, 
			success: function(xml){
				$(xml).find("_PAGE_").each(function(){
					var pageId = $(this).attr("id");
					if (pageId) {
						scui.frag[pageId] = $(this).text();
						alert(scui.frag[pageId]);
						//alert()
					}
				});
			}
		});
*/
	},
	initSimple : function () {
		var keys = new Array("dialogFrag","mask","combox");//
		var values = new Array("<DIV style='BORDER-BOTTOM: #8eb5db 1px solid; POSITION: absolute; BORDER-LEFT: #8eb5db 1px solid;DISPLAY:block;BACKGROUND:url(img/pop_03.gif) #FFFFFF repeat-x 0px 0px; FLOAT: left;BORDER-TOP: #8eb5db 1px solid;BORDER-RIGHT: #8eb5db 1px solid;' id=popmessage class=popmessage><LI style='BORDER-BOTTOM: #8eb5db 1px solid; WIDTH: 105%; DISPLAY: block; FLOAT: left; HEIGHT: 30px; COLOR: #0e4796; FONT-SIZE: 12px; FONT-WEIGHT: bold;background:#f1f1f1;' id=popTitle class=popTitle><DIV style='PADDING-BOTTOM: 0px; PADDING-LEFT: 15px; PADDING-RIGHT: 0px; FLOAT: left; PADDING-TOP: 8px' id=titlename></DIV><DIV style='MARGIN: 8px 10px 0px 0px; WIDTH: 15px; DISPLAY: block; BACKGROUND: url(images/popClose.gif) no-repeat; FLOAT: right; HEIGHT: 15px; CURSOR: pointer;' id=popClose></DIV></LI><LI style='PADDING-BOTTOM: 10px;PADDING-LEFT: 30px; PADDING-RIGHT: 25px; DISPLAY: block;width:auto;FLOAT: left;PADDING-TOP: 15px;' id=popcontent class=popcontent><div style='display:block;float:left;font-size:12px; font-weight:bold; padding:0 0 0 20px;'>加载中...</div></LI><LI style='TEXT-ALIGN: center; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; DISPLAY: block; FLOAT: left; HEIGHT: 20px; VERTICAL-ALIGN: middle; PADDING-TOP: 5px;PADDING-BOTTOM: 5px' id=popbottom class=popbottom><INPUT style='display:none;' id=msg_btn_ok class=popButton value=确定 type=button name=btnok><INPUT style='display:none;' id=msg_btn_no class=popButton value=否 type=button name=btnno><INPUT style='display:none;' id=msg_btn_cancel class=popButtonCancel value=取消 type=button name=btncancel></LI></DIV>","<div id='div_mask' class='el-static-mask' style='top: 0pt; left: 0pt; width: 1263px; height: 406px;display:none;'></div>","<div class='combox'></div>");
		for (var i=0;i<3;i++) {
			var pageId = keys[i];
			var value = values[i];
			scui.frag[pageId] = value;
		}
	},
	doSubmit: function(param,success,failure,divObj){
		var theForm = $("#"+param,"body");
		var url = (theForm.attr("id")) ? theForm.attr("action") : param;
		//alert(url);
		//alert(theForm.serialize());
		//$.ajaxSetup({
		//	contentType : "application/x-www-form-urlencoded;charset=utf-8"
		//});
		jQuery.ajax({ 					
			type:"POST",
			contentType : "application/x-www-form-urlencoded;charset=ISO-8859-1",
			data:theForm.serializeArray(),
			dataType:"json",
			url:url,
			cache:false,
			error:function(json,error){
				alert("AJAX ERROR :"+error);
			},
			success: function(json){
				//if (json.statusCode == scui.statusCode.ok) {
				if (json.success == "true") {
					//alert(json.statusCode);
					if (divObj) {
						//var _url = json.viewsuccess;
						$("#"+divObj).html(_url);
					}
					if (typeof(success) == 'function') {
						success(json);
					}					
				}
				//else if (json.statusCode == scui.statusCode.error) {
				else if (json.success == "false") {
					var errormessage = json.errormessage;
					$.dialog.alertMsg(errormessage);
					if (typeof(failure) == 'function') {
						failure();
					}		
				}
			}
		});
	},
	doQuery: function(param,success,failure,divObj) {
		//var selfbody = $("body",top.document);
		var url;
		var thediv;
		var theForm = $("#"+param);
		if (!(theForm.attr("id"))) {
			theForm = $("#"+param,top.document);
			if (!(theForm.attr("id"))) {
				url = param;
			  thediv = $("#"+divObj);
			}
			else {
				url = theForm.attr("action");
				thediv = $("#"+divObj,top.document);
			}
		}
		else {

			url = theForm.attr("action");
			thediv = $("#"+divObj);
		}
		//var url = (theForm.attr("id")) ? theForm.attr("action") : param;
		//alert(url);
		jQuery.ajax({
			type:"GET",
			data:theForm.serializeArray(),
			url:url,
			cache:false,
			error:function(json,error){
				//alert(json);
				alert("AJAX ERROR :"+error);
			},
			success: function(json){

//				if (json.success == "true") {

				if (typeof(success) == 'function') {
					success();
				}		
				//alert(json);
				thediv.html(json);
				var dialog = $.dialog.getCurrent();
				//当dialog高度改变时，修改dialog位置
				if (dialog) {
					//alert(top.document.body.clientHeight);
					dialog.css({"top":(top.document.body.clientHeight-dialog.height())/2,"left":(top.document.body.clientWidth - dialog.width())/2});	
					$.dialog.showAndHideLoading();
				}
	/*
				}
				//else if (json.statusCode == scui.statusCode.error) {
				else if (json.success == "false") {
					var errormessage = json.errormessage;
					$.dialog.alertMsg(errormessage);
					if (typeof(failure) == 'function') {
						failure();
					}		
				}
				*/
			}
		});	
	},
	doRefresh : function (param,divObj) {
		//alert(param)		
		jQuery.ajax({
			type:"POST",
			//contentType:"application/x-www-form-urlencoded;charset=utf-8",
			url:"MainServlet.action",
			data:param,
			cache:false,
			contentType:"application/x-www-form-urlencoded;charset=iso-8859-1",
			error:function(json,error){
				alert("AJAX ERROR :"+error);
			},
			success: function(json){		
				$("#"+divObj).html(json);
				document.getElementById("pkvalue").value="";
			}
		});			
	},
	sleep : function (numberMillis) {  
		var now = new Date();    
		var exitTime = now.getTime() + numberMillis;   
		while (true) { 
			now = new Date();       
			if (now.getTime() > exitTime) 
			return;    
		} 
	}	
};

(function($){
	$.fn.extend({
		loadUrl: function(url,data,callback){
			$this = $(this);
			$.ajax({
				type: 'POST',
				url: url,
				cache: false,
				dataType:"html",
				data:data,
				success: function(response){
					//alert(response);
					$this.html(response);
					var dialog = $.dialog.getCurrent();
					//当dialog高度改变时，修改dialog位置
					if (dialog) {
						dialog.css({"top":(top.document.body.clientHeight-dialog.height())/2,"left":(top.document.body.clientWidth - dialog.width())/2});	
						$.dialog.showAndHideLoading();
					}
					scui.initSimple();
				}
			});
		}
	});
})(jQuery);
/**
 * 
 * 
 */
(function($){
	$.dialog = {
		_op:{height:0, width:0, minH:0, minW:0, total:0, max:false, mask:false, resizable:true, maxable:true,minable:true,fresh:true},
		_current:null,
		maskloading:null,
		drawable:false,
		_zIndex:42,
		sum:0,
		test:function () {
			alert("test");
		},
		setCurrent:function(){
			var maincontent = top.document.getElementById("maincontent");
			//alert(maincontent);
			//$(mainspan).append(scui.frag["dialogFrag"]);
			var $maincontent = $(maincontent);			
			var max = 0,temp = 0;
			var dialog = $(">.popmessage", $maincontent);
			for (var i=0;i<dialog.length;i++) {
				if (dialog.eq(i).css("zIndex") > max) {
					max = dialog.eq(i).css("zIndex");
					temp = i;
				}
			};
			$.dialog._current = (dialog.length == 0) ? "" : dialog.eq(temp);
		},
		getCurrent:function(){
			return this._current;
		},
		//打开一个窗口
		open:function(w,h,l,t,title,button,maskFlag,alertFlag,param1,confirm,cancle,param2) {
			/*		  	
			1.w-----------宽[默认:240]
			2.h-----------高[默认:120]
			3.l-----------距离左边的位移
			4.t-----------距离顶部的位移
			5.title-------标题[默认:提示窗口]
			6.button------按钮[1代表隐藏,0代表显示]
			7.maskFlag----是否带有阴影层[0|1]
			8.alertFlag---弹出框类型[error|confirm|msg|url]
			9.param1------参数1，表示的内容依alertFlag类型的不同而有所区别；
						  1.alertFlag=msg-->信息内容
						  2.alertFlag=url-->页面地址
			10.confirm-----确定事件
			11.cancle------取消事件
			12.param2-----参数2[预留参数]
			alert(w+","+h+","+maskFlag++","+alertFlag+","+param1+","+param2);
			*/
			var maincontent = top.document.getElementById("maincontent");
			var $maincontent;
			//$(mainspan).append(scui.frag["dialogFrag"]);
			var maskH = top.document.body.scrollHeight;
			var isWindow = 0;
			if (maincontent) {
				$maincontent = $(maincontent);
			}
			else {
				$maincontent = $("body");
				maskH = document.body.scrollHeight;
				isWindow = 1;
			}
			//alert("dialog="+scui.frag["dialogFrag"]);
			$maincontent.append(scui.frag["dialogFrag"]);
			dialog = $(">.popmessage:last-child", $maincontent);//用所有的class为message_pane的全部元素来找					
			$.dialog.sum++;
			var W = w || 240;
			var H = h || "auto";
			var L = l || (top.document.body.clientWidth - 240)/2;
			//var T = t || $("body").scrollTop() + 250;	
			var T = t || ((top.document.body.clientHeight-dialog.height())/2) - 50;
			if (isWindow == 1){
				T = t || ((top.document.body.clientHeight-dialog.height())/2) - 50+document.body.scrollTop;	
			}
			
//			var L = l || (window.screen.availWidth - 240)/2;
//			var T = t || ((top.document.body.clientHeight-dialog.height())/2) - 50;	
//			alert(screen.availHeight/2);
			var title = title || "提示信息";
			dialog.css({"zIndex":($.dialog._zIndex+=2),"width":W,"left":L,"top":T}).find("#titlename").text(title);
			dialog.data("dialogId",Math.round(Math.random()*10000000));
			
			if (maskFlag && maskFlag == "1") {
				var i = $.dialog._zIndex - 3;
				if ($.dialog._current) i = Number($.dialog._current.css("zIndex")) + 1;
				//$("body").append(scui.frag["mask"]);
				$maincontent.append(scui.frag["mask"]);
				//mask = $(">.el-static-mask:last-child", $maincontent);
				var mask = $(">.el-static-mask:last-child", $maincontent);
				mask.data("dialogId",dialog.data("dialogId")).css({"zIndex":i,"height":maskH,"width":top.document.body.scrollWidth}).show();
				$.dialog.maskloading = mask.find("div");
				//屏蔽按键
				$(document).keydown(function (event) {		   
					if (event.keyCode == 8) {	
						if (top.document.activeElement.type != "text" || event.srcElement.type != "text"){
							event.preventDefault();
							event.returnValue = false;
							return true;
						}
					}
					else if (event.keyCode == 13) {
							event.preventDefault();
							event.returnValue = false;
							return true;							
					}
				});					
				$maincontent.keydown(function (event) {		   
					if (event.keyCode == 8) {	
						if (top.document.activeElement.type != "text" || event.srcElement.type != "text"){
							event.preventDefault();
							event.returnValue = false;
							return true;
						}
					}
					else if (event.keyCode == 13) {
							event.preventDefault();
							event.returnValue = false;
							return true;							
					}
				});					
				$(top.document).keydown(function (event) {		   
					if (event.keyCode == 8) {	
						if (top.document.activeElement.type != "text" || event.srcElement.type != "text"){
							event.preventDefault();
							event.returnValue = false;
							return true;
						}
					}
					else if (event.keyCode == 13) {
							event.preventDefault();
							event.returnValue = false;
							return true;							
					}
				});				
			}			
			$.dialog._current = dialog;
		  //判断button显示的设置	 
		  if(button){
			if(button.substring(0,1) == '0'){
			  dialog.find("#msg_btn_ok").show();
			}
			if(button.substring(1,2) == '0'){
			  dialog.find("#msg_btn_no").show();
			}
			if(button.substring(2,3) == '0'){
			  dialog.find("#msg_btn_cancel").show();
			}
		  }
		  else{  //默认显示ok和cancel
			dialog.find("#msg_btn_ok").show();
			dialog.find("#msg_btn_cancel").show();
		  }
			//move
			dialog.find("#popTitle").mousedown(function (e) {
				thisdialog = $(this).parents(".popmessage");
				$.dialog._current = thisdialog;
				thisdialog.css({"zIndex":($.dialog._zIndex+=2)});
				$.dialog.drawable = true;
				var position = thisdialog.position();
//				alert(position);
				var X = e.clientX-position.left;
				var Y = e.clientY-position.top;
				document.onselectstart=new Function('event.returnValue=false;');
				$maincontent.mousemove(function (e) {			  
					if ($.dialog.drawable == true) {
						var clientX = e.clientX;
						var clientY = e.clientY;
						thisdialog.css({"left":(clientX-X)+"px","top":(clientY-Y)+"px"});
					}
				});
			});	
							
			dialog.find(".popTitle").mouseup(function (e) {
				document.onselectstart=new Function('event.returnValue=true;');
				$.dialog.drawable = false;
				$maincontent.unbind("mousemove");
			});
			//move结束
			dialog.find("#msg_btn_cancel").click(function () {
				if (typeof(cancle) == 'function') {
					cancle();
				}	
				else {
					$.dialog.close("",$(this));
				}			
			});
			dialog.find("#popClose").click(function () {
				if (typeof(cancle) == 'function') {
					cancle();
				}
				else {
					$.dialog.close("",$(this));
				}		
			});
			if (typeof(confirm) == 'function') {
				dialog.find("#msg_btn_ok").click(function () {
					confirm();
				});
			}							
			if (alertFlag == "error") {
				
			}
			if (alertFlag == "msg") {
				dialog.find("#popcontent").css({"height":h});
				var content = $("#popcontent",dialog);
				content.html(param1);	
				$.dialog.maskloading.hide();
			}
			if (alertFlag == "url") {
				dialog.hide();
				H = dialog.height();
				var T = t || (document.body.clientHeight-H)/2;
				dialog.css({"top":T});
				var content = $("#popcontent",dialog);
				content.loadUrl(param1);
			}
			dialog.find("#msg_btn_ok").focus();
		},
		reload:function (url,index) {//如果不指定索引值，默认则重载当前dialog
			var dialog = (index) ? $(">.popmessage", $maincontent).eq(index) : $.dialog._current;
			var content = $("#popcontent",dialog);
			content.loadUrl(url);
		},
		close:function (current,$this) {
			var maincontent = top.document.getElementById("maincontent");
			var $maincontent;
			//$(mainspan).append(scui.frag["dialogFrag"]);
			if (maincontent) {
				$maincontent = $(maincontent);
			}
			else {
				$maincontent = $("body");
			}
			var dialogId;
			if (current) {
				dialogId = current.data("dialogId");
				current.html("");
				current.remove();
			}
			else if ($this) {
				var dialog = $this.parents(".popmessage");
				dialogId = dialog.data("dialogId");
				dialog.html("");
				dialog.remove();		
			}
			var masks = $(">#div_mask", $maincontent);
			$.each(masks,function(i){
				var maskdialogId = masks.eq(i).data("dialogId");
				if (dialogId == maskdialogId) {
					masks.eq(i).remove();
					return false;
				}
			});
			$.dialog.setCurrent();
			$.dialog.sum--;
			$(document).unbind("keydown");
			$maincontent.unbind("keydown");
			$(top.document).unbind("keydown");
		},
		closeCurrent:function () {
			$.dialog.close($.dialog._current);
		},
		showAndHideLoading:function () {
			$.dialog._current.show();
			$.dialog.maskloading.hide("");
		},
		startEvent:function (f) {
			f();
			$.dialog.closeCurrent();
		},
		stopEvent:function () {
			$.dialog.closeCurrent();
			return false;
		},
		alertMsg:function (m) {
			$.dialog.open("","","","","","011","1","msg","<div style='display:block;width:auto;height:auto;font-size:12px; font-weight:bold;'>"+m+"</div>",$.dialog.closeCurrent);
		},
		alertConfirm:function (m,f,btn) {
			$.dialog.open("","60","","","",btn,"1","msg","<div style='display:block;width:185px;height:auto;font-size:12px;font-weight:bold;word-wrap:break-word;'>"+m+"</div>",f,$.dialog.stopEvent);
		},
		alertConfirmCancle:function (m,f,cf,btn) {
			$.dialog.open("","","","","",btn,"1","msg","<div style='display:block;width:185px;height:auto;font-size:12px;font-weight:bold;word-wrap:break-word;'>"+m+"</div>",f,cf,$.dialog.stopEvent);
		}			
	};
})(jQuery);
(function($) {
	$.stable = {
		addTr:function (tableId) {
			var id = tableId || "";
			var table = $("#"+tableId,"body");
			var maxline = table.attr("maxline");
			if (maxline) {
				var line = table.find("tr").length - 1;
				if (line == maxline) {
					$.dialog.alertMsg("最多只能添加"+maxline+"条!");
					return false;
				}
			}
			var newTr = table.find(".std").first().clone(true);
			var inputs = newTr.find("input").not(":button");
			//var drn = newTr.find("#divRecordNumber").text();
			//newTr.find("#divRecordNumber").text(Number(drn) + 1);
			var l = $("tr",table).length - 1;
			newTr.find("#divRecordNumber").text(Number(l) + 1);
			$.each(inputs,function(i){
				var thename = inputs.eq(i).attr("name");
				var theid = inputs.eq(i).attr("id");
				inputs.eq(i).attr({"name":thename+l,"id":theid+l}).val("");
			});
			var inputs = $("input",newTr);
			//alert(inputs.length);
			for (var i=0;i<inputs.length;i++) {
				if (inputs.eq(i).attr("setItem")) {
					var setItems = inputs.eq(i).attr("setItem");
					//alert(setItems);
					var setItem = setItems.split(",");
					var newSetItem = "";
					for (var j=0;j<setItem.length;j++) {
						setItem[j] = setItem[j]+l;
						newSetItem += "," + setItem[j];
					}
					newSetItem = newSetItem.substring(1,newSetItem.length);
					inputs.eq(i).attr("setItem",newSetItem);
				}
			};
			table.append(newTr);
		},
		delTr:function (tableId,index) {
			var table = $("#"+tableId,"body");
			var theTr;
			if (table.find(".std").length > 1) {
				theTr = (index) ? table.find(".std").eq(index) : table.find(".std").last();
				theTr.remove();	
			}	
		},
		delThisTr:function (input) {
			var $this = $(input);
			var table = $this.parents("table");
			if (table.find(".std").length > 1) {
				$this.parents("tr").remove();
				var trs = table.find(".std");
				$.each(trs,function(i) {
					trs.eq(i).find("#divRecordNumber").text(i+1);
				});
			}
		}
	};
})(jQuery);
(function($) {
	$.combox = {
		oldValue : "",
		doSelect:function(input,isDm,isMulti,isNull,event){	
			/*
			1.input--this
			2.isDm --是否含有代码[1,0]
			3.isMulti--是否允许选取多个[1,0]
			4.isNull--是否含有赋空
			5.event--触发事件的源[调试参数]
			*/
			$this = $(input);
			$.combox.oldValue = $this.val();
			if ($(".combox", "body").length > 0) {
				$.combox.removeCombox();
			}
		    $("body").append(scui.frag["combox"]).click(function (e) {
				var src = e.target || window.event.srcElement;  					  
				if ($(src).attr("setItem")) {
					return false;
				}
				else {
					$.combox.removeCombox();
				}
			});
			combox = $(">.combox:last-child", "body");
			var w = $this.width() + 1;
			var h = $this.height() + 5;
			var position = $this.position();
			combox.css({"left":position.left,"top":position.top + h,"width":w + "px"});
			var cols;
			var col;
			var setItems = $this.attr("setItem");
			var setItem = setItems.split(",");
			//alert(setItems);

			if ($this.attr("comboxValue")){
				cols = $this.attr("comboxValue");
				col = scui.jsonEval(cols);		
				//col = cols.split(",");
				$.each(col,function(i,n) {
					//alert(i);alert(n);	
					if (isDm == "1") {
						combox.append("<li><div class='cleft'></div></li>");
						var comboxValue = $(">li:last-child", combox);
						comboxValue.append("<div class='ctext'>"+n+"</div>").width(w).data("param",{"p1":i,"p2":n}).find(".cleft").append(i);					
					}
					else if (isMulti == "1") {
						var ifcheck = "checked";
						if(input.value.indexOf(n)<0){
							
							ifcheck = "";
						}
						combox.append("<li><div class='cleft' style='width:20px;height:20px;'><input class='chkSelect' type='checkbox' "+ifcheck+"/></div></li>");					
						var comboxValue = $(">li:last-child", combox);
						comboxValue.append("<div class='ctext'>"+n+"</div>").width(w).data("param",{"p1":i,"p2":n})
						.find(".chkSelect").attr({"chkSelect":n,"valuedm":i})
						.data("param",{"p1":i,"p2":n})
						.bind("click",function (event){
							event.stopPropagation();
							var checkeds = combox.find(":checked");
							var valuedm = "";
							var chkSelect = "";						
							$.each(checkeds,function(i){
								valuedm += ","+checkeds.eq(i).attr("valuedm");
								chkSelect += ","+checkeds.eq(i).attr("chkSelect");
							});
							valuedm = valuedm.substring(1,valuedm.length);
							chkSelect = chkSelect.substring(1,chkSelect.length);								
							if (setItem.length > 1) {
								$("#"+setItem[0],"body").val(valuedm);
								$("#"+setItem[1],"body").val(chkSelect);
							}
							else if (setItem.length = 1){
								$("#"+setItem[0],"body").val(valuedm);
							}
						});
												


					}
					else {
						combox.append("<li></li>");	
						var comboxValue = $(">li:last-child", combox);
						comboxValue.append("<div class='ctext'>"+n+"</div>").width(w).data("param",{"p1":i,"p2":n});	
					}
					$(".cleft",combox).click(function(event) {
						event.stopPropagation();							  
					});
					comboxValue.click(function () {	
						if ($this.attr("setItem")) {
							if (setItem.length > 1) {
								var value1 = $(this).data("param").p1;
								var value2 = $(this).data("param").p2;
								
								$("#"+setItem[0],"body").val(value1);
								$("#"+setItem[1],"body").val(value2);
							}
							else if (setItem.length = 1){
								var value = $(this).data("param").p2;
								$("#"+setItem[0],"body").val(value);
							}
						}
						$.combox.removeCombox();
					});
				});	
				$(">li:even", combox).css({"background":"#f5f7f9"});
				if (combox.height() > 280) {
					combox.css({"height":280,"overflow-y":"auto"});
				}
				if (isMulti == "1"){
					combox.append("<li style='border-top:1px solid #FFFFFF;'><div class='selectall' id='selectall'>全选</div><div class='unselectall' id='unselectall'>清除</div><div class='close' id='close'>关闭</div></li>");
					var _checkeds = combox.find(".chkSelect");
					var _valuedm = "";
					var _chkSelect = "";
					$.each(_checkeds,function(i){
						_valuedm += ","+_checkeds.eq(i).attr("valuedm");
						_chkSelect += ","+_checkeds.eq(i).attr("chkSelect");
					});
					_valuedm = _valuedm.substring(1,_valuedm.length);
					_chkSelect = _chkSelect.substring(1,_chkSelect.length);			
					$("#selectall").click(function(event) {
						event.stopPropagation();
							$(".chkSelect",combox).attr("checked","checked");
							if (setItem.length > 1) {
								$("#"+setItem[0],"body").val(_valuedm);
								$("#"+setItem[1],"body").val(_chkSelect);
							}
							else if (setItem.length = 1){
								$("#"+setItem[0],"body").val(_valuedm);
							}						
					});
					$("#unselectall").click(function(event) {
						event.stopPropagation();
							$(".chkSelect",combox).removeAttr("checked","checked");	
							if (setItem.length > 1) {
								$("#"+setItem[0],"body").val("");
								$("#"+setItem[1],"body").val("");
							}
							else if (setItem.length = 1){
								$("#"+setItem[0],"body").val("");
							}						
					});
					$("#close").click(function () {
						$.combox.removeCombox();
					});
				}
				if (isNull == "1") {
					combox.append("<li style='border-top:1px solid #FFFFFF;'><div class='setnull' id='setnull' style='width:244px;'>无</div></li>");
					$("#setnull").click(function (event) {
						event.stopPropagation();
						if (setItem.length > 1) {
							$("#"+setItem[0],"body").val("");
							$("#"+setItem[1],"body").val("");						
						}
						else if (setItem.length = 1){
							$("#"+setItem[0],"body").val("");
						}	
						$.combox.removeCombox();
					});
				}
			}
			else {
				combox.append("<li><div class='ctext'>无有效数据</div></li>");
			}
		},
		removeCombox:function () {
			var com = $(">.combox", "body");
			$(">li", com).removeData("param");
			com.empty().remove();
			$("body").unbind("click");
			var newValue = $this.val();
			if ($.combox.oldValue != newValue) {
				var onChange = $this.attr("onChange");
				if(onChange!=null&&onChange!='undefined')
				onChange();
			}
			return false;			
		}
	};
})(jQuery);